package com.fun.profile;

import com.fun.httpclient.FanLibrary;
import org.apache.http.Header;
import org.apache.http.protocol.HTTP;

import java.util.Arrays;
import java.util.List;

/**
 *
 */
public class HttpClientConstant {
    /**
     * 默认user_agent
     */
    public static final String USER_AGENT = "okhttp/3.10.0";
    /**
     * 从连接池中获取可用连接最大超时时间 单位：毫秒
     */
    public static final int CONNECT_REQUEST_TIMEOUT = 5 * 1000;
    /**
     * 连接目标url最大超时 单位：毫秒
     */
    public static final int CONNECT_TIMEOUT = 5 * 1000;
    /**
     * 等待响应（读数据）最大超时 单位：毫秒
     */
    public static final int SOCKET_TIMEOUT = 5 * 1000;
    /**
     * 连接池最大连接数
     */
    public static final int MAX_TOTAL_CONNECTION = 1000;
    /**
     * 每个路由最大连接数
     */
    public static final int MAX_PER_ROUTE_CONNECTION = 200;
    /**
     * 最大header数
     */
    public static final int MAX_HEADER_COUNT = 100;
    /**
     * 消息最大长度
     */
    public static final int MAX_LINE_LENGTH = 10000;
    /**
     * 设置的本机ip
     */
    public static final String IP = SysInit.getRandomIP();
    /**
     * 重试次数
     */
    public static final int TRY_TIMES = 3;
    /**
     * 关闭超时的链接
     */
    public static final int IDLE_TIMEOUT = 100;
    /**
     * 在设置请求contenttype参数，表示请求以io流发送数据
     */
    public static final String CONTENTTYPE_MULTIPART_FORM = "multipart/form-data";
    /**
     * 在设置请求contenttype参数，表示请求以文本发送数据
     */
    public static final String CONTENTTYPE_TEXT = "text/plain";
    /**
     * SSL版本
     */
    public static final String SSL_VERSION = "TLSv1.2";

    /**
     * 公共的header集合
     */
    public static final List<Header> COMMON_HEADER = Arrays.asList(FanLibrary.getHeader("X-FORWARDED-FOR", HttpClientConstant.IP), FanLibrary.getHeader("Proxy-Client-IP", HttpClientConstant.IP), FanLibrary.getHeader("WL-Proxy-Client-IP", HttpClientConstant.IP), FanLibrary.getHeader(HTTP.USER_AGENT, HttpClientConstant.USER_AGENT), FanLibrary.getHeader("Connection", "keep-alive"));
}
